#coding:utf8
from django.shortcuts import render_to_response
from models import Template

from google.appengine.api import users

def index(request):
    
    user = users.GetCurrentUser()
    if not user:
        greeting = ("<a href=\"%s\">需要登录Google帐号，点击进行登录</a>." % 
                    users.create_login_url("/"))        
        return render_to_response('msg.html', {'msg':greeting, 'url':'/'})
    
    key = request.GET.get('key', '')
    userTemp = Template.gql("WHERE owner =:owner", owner = user)
     
    for temp in userTemp:
        if temp.key().__str__() == key:
            temp.delete()
            return render_to_response('msg.html', {'msg': '删除模版成功！', 'url':'/'})
       
    return render_to_response('msg.html', {'msg': '参数错误,也不到此模版！，删除失败！', 'url':'/'})
        
if __name__ == '__main__':
    pass